<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>电动汽车数据分析</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            margin: 20px;
            background-color: #f8f9fa;
            color: #333;
        }
        .container {
            max-width: 1400px;
            margin: 0 auto;
        }
        .header {
            text-align: center;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 30px;
            border-radius: 10px;
            margin-bottom: 30px;
        }
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 30px;
        }
        .stat-card {
            background: white;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
        .stat-value {
            font-size: 24px;
            font-weight: bold;
            color: #667eea;
        }
        .stat-label {
            font-size: 14px;
            color: #666;
        }
        .plot {
            background: white;
            margin: 20px 0;
            padding: 25px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
        }
        .plot h2 {
            color: #444;
            border-bottom: 2px solid #667eea;
            padding-bottom: 10px;
            margin-top: 0;
        }
        .plot img {
            width: 100%;
            height: auto;
            border-radius: 5px;
        }
        .footer {
            text-align: center;
            margin-top: 40px;
            color: #666;
            font-size: 14px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1>🚗 电动汽车数据分析仪表板</h1>
            <p>基于电动汽车数据的全面分析和可视化</p>
        </div>

        <!-- 统计摘要 -->
        <div class="stats-grid">
            <div class="stat-card">
                <div class="stat-value">{{ plots.summary_stats.total_vehicles }}</div>
                <div class="stat-label">总车辆数</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ plots.summary_stats.unique_brands }}</div>
                <div class="stat-label">品牌数量</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ plots.summary_stats.unique_models }}</div>
                <div class="stat-label">车型数量</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ plots.summary_stats.years_range }}</div>
                <div class="stat-label">年份范围</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ plots.summary_stats.avg_battery_capacity }} kWh</div>
                <div class="stat-label">平均电池容量</div>
            </div>
            <div class="stat-card">
                <div class="stat-value">{{ plots.summary_stats.avg_range }} km</div>
                <div class="stat-label">平均续航</div>
            </div>
        </div>

        <!-- 各图表 -->
        <div class="plot">
            <h2>📊 各品牌车辆数量分布</h2>
            <img src="data:image/png;base64,{{ plots.brand_distribution }}" alt="品牌分布">
        </div>

        <div class="plot">
            <h2>🌍 各地区车辆分布</h2>
            <img src="data:image/png;base64,{{ plots.region_distribution }}" alt="地区分布">
        </div>

        <div class="plot">
            <h2>🔋 电池容量与续航关系</h2>
            <img src="data:image/png;base64,{{ plots.battery_vs_range }}" alt="电池与续航关系">
        </div>

        <div class="plot">
            <h2>🚙 车辆类型分布</h2>
            <img src="data:image/png;base64,{{ plots.vehicle_type_distribution }}" alt="车辆类型分布">
        </div>

        <div class="plot">
            <h2>⏱️ 充电时间分布</h2>
            <img src="data:image/png;base64,{{ plots.charging_time_distribution }}" alt="充电时间分布">
        </div>

        <div class="plot">
            <h2>❤️ 电池健康度分析</h2>
            <img src="data:image/png;base64,{{ plots.battery_health_distribution }}" alt="电池健康度分析">
        </div>

        <div class="plot">
            <h2>⚡ 平均速度与能耗关系</h2>
            <img src="data:image/png;base64,{{ plots.speed_vs_energy_consumption }}" alt="速度与能耗关系">
        </div>

        <div class="footer">
            <p>数据分析仪表板 | 基于Python Flask + Pandas + Matplotlib构建</p>
        </div>
    </div>
</body>
</html>